<template>
	<view>
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="item,index in swiperData">
				<view class="swiper-item">
					<img :src="'http://localhost:8090/foodapp'+item.icon" alt="" style="width: 100%;"/>
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperData:[{
					 "id": 1,
					      "name": "烤鸭",
					      "label": "烤鸭烤鸭烤鸭",
					      "icon": "/images/1.png",
					      "price": 88,
					      "description": "烤鸭烤鸭烤鸭烤鸭烤鸭",
					      "type": "肉类"
				}]
			}
		},
		methods: {
			
		},
		onLoad() {
			uni.request({
				url:'http://localhost:8090/foodapp/food/list',
				method:'POST',
				data:{},
				success: (res) => {
					if(res.data.success){
						this.swiperData=res.data.data
						uni.showToast({
							title:'成功'
						})
					}else{
						uni.showToast({
							title: '失败',
							icon:'none'
						});
					}
				},
				fail: () => {
					uni.showToast({
						title: '网络错误',
						icon:'none'
					});
				},
				complete: () => {
					
				}
			})
		}
	}
</script>

<style>

</style>
